clear; close all; clc
 addpath('../LibForSerial/LibrarySLP','../LibForSerial/LibraryLeSage/');

%----------- Load shocks using two identification schemes ----------------%
LogVsLevel = 0; 
  NumberConsecutiveshocks = 2; % 1 previous shocks that is  positive, and the 2nd one is positive too 
cd ../Figure2_4_EPU/DataShocks/
  LoadShocksMandQpositiveEPUrevisedMAC; 
cd ../../Figure1_EPU

%sample=[ 1985 1; 2019  12]; ss_ = find(dates_EPU ==198501);
 sample=[ 1986 1; 2019  12]; ss_ = find(dates_EPU ==198601);
                             se_ = find(dates_EPU ==201912);
  uEPU   =   uEPU(ss_:se_);
  logEPU = logEPU(ss_:se_);
  
ushock = uEPU;
 %% Pictures for paper
[Years,M] = meshgrid(1986:2019, 1:1:12);
calM = datenum([Years(:), M(:), 28*ones(numel(Years),1)]); % The Serial Dates

ticks = datenum([(1989:6:2019)',12*ones(6,1), 28*ones(6,1) ]);
lim_x =[datenum(  1986,1,1), datenum(2019,12,31)];

LineWidth =  4.0;   
%-------------------------------------------------------------------------%
%% Figure 1 - Panel (g) and (h)
figure(1) 
subplot(2,1,1)
 h_0 = line(calM(1:end),     logEPU, 'linewidth',LineWidth);      title(['Time Series of EPU'])
  set(gca, 'XLim' , lim_x)
set(gca, 'XTick', ticks)
datetick('keepticks','keeplimits')
box on
recessionplot
set(gca,'FontSize',32)

subplot(2,1,2) 
 h_1 = line(calM(1:end),     ushock, 'linewidth',LineWidth);      title(['Time Series of EPU shocks'])
hold on
      line(calM(1:end) , 2*ones(size(calM(1:end),1),1),'color','k','linewidth',LineWidth);
      line(calM(1:end) ,-2*ones(size(calM(1:end),1),1),'color','k','linewidth',LineWidth);     
h_0  =line(calM(1:end) , 0*ones(size(calM(1:end),1),1),'color','r','linewidth',LineWidth/2);
uistack(h_0, 'top')


  set(gca, 'XLim' , lim_x)
set(gca, 'XTick', ticks)
datetick('keepticks','keeplimits')
box on
recessionplot
set(gca,'FontSize',32)